import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as session from 'express-session';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { ValidationPipe } from '@nestjs/common';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

    const config = new DocumentBuilder()
    .setTitle('New-King')
    .setDescription('The New-King API description')
    .setVersion('0.1')
    .addBearerAuth()
    .build();
    const document = SwaggerModule.createDocument(app, config); 
    SwaggerModule.setup('api', app, document);

    app.use(session({
      secret: 'newking',
      resave: false,
      saveUninitialized: false
    }));

    app.useGlobalPipes(new ValidationPipe());
    app.enableCors();
    await app.listen(3000);
}
bootstrap();
